angular.module('mamApp').controller('cpPlayOverviewController', ['$scope', '$state', 'DataManager','api','paramsManager',
    function ($scope, $state, DataManager, api, paramsManager) {

    $scope.search = {
        pageNo: $state.params.pageNo || 1,
        pageSize: $state.params.pageSize || 10,
        key: $state.params.key || "",
        value: $state.params.value || "",
        "X-Auth-Token":$scope.userInfo.token
    };

    $scope.paginationConf = {
        currentPage: $state.params.pageNo || 1,
        itemsPerPage: $state.params.pageSize || 10,
        pagesLength: 9,
        search: 0,
        onChange: function () {
            $scope.search.pageNo = this.currentPage;
            $scope.search.pageSize = this.itemsPerPage;
            $state.go($state.current.name, $scope.search)
        }
    };

    //select选择条件
    $scope.fileNames = [{key: "", value: "查找字段"}, {key: "cpId", value: "CP_ID"}, {key: "userName", value: "CP昵称"}];

    //搜索
    $scope.findData = function () {
        $state.go($state.current.name, $scope.search)
    };

    //下载
    $scope.downHref = api + "/admin/stat/play/cp/excel" + paramsManager.query($scope.search);

    //列表
    $scope.noPermission=false;
    DataManager.cpPlayOverviewStat([$scope.search.pageNo, $scope.search.pageSize], $scope.search).then(function (result) {
        if(result.data.c=="n"){
            $scope.noPermission=true;
        }else{
            $scope.noPermission=false;
            $scope.cpPlayOverviewList = result.data.pageList;
            $scope.paginationConf.totalItems = result.data.total;
        }
    });




}]);

